import httpRequest from '@/config/axios/httpRequest'
import {
  CreateProcessExpressionReq,
  CreateProcessExpressionResp,
  DeleteProcessExpressionResp,
  ProcessExpressionPageReq,
  ProcessExpressionResp,
  UpdateProcessExpressionReq,
  UpdateProcessExpressionResp
} from '@/models/bpm/ProcessExpressionModel'
import bpmapi from '../bpmapi'

// BPM 流程表达式 API
export const ProcessExpressionApi = {
  // 查询BPM 流程表达式分页
  getProcessExpressionPage: async (params: ProcessExpressionPageReq) => {
    return await httpRequest.get<ProcessExpressionResp>(bpmapi.BpmGetProcessExpressionPage, {
      params
    })
  },

  // 查询BPM 流程表达式详情
  getProcessExpression: async (id: number) => {
    return await httpRequest.get(bpmapi.BpmGetProcessExpression, { params: { Id: id } })
  },

  // 新增BPM 流程表达式
  createProcessExpression: async (data: CreateProcessExpressionReq) => {
    return await httpRequest.post<CreateProcessExpressionResp>(
      bpmapi.BpmCreateProcessExpression,
      data
    )
  },

  // 修改BPM 流程表达式
  updateProcessExpression: async (data: UpdateProcessExpressionReq) => {
    return await httpRequest.put<UpdateProcessExpressionResp>(
      bpmapi.BpmUpdateProcessExpression,
      data
    )
  },

  // 删除BPM 流程表达式
  deleteProcessExpression: async (id: number) => {
    return await httpRequest.delete<DeleteProcessExpressionResp>(
      bpmapi.BpmDeleteProcessExpression,
      { params: { Id: id } }
    )
  },

  // 导出BPM 流程表达式 Excel
  exportProcessExpression: async (params) => {
    return await httpRequest.download(bpmapi.BpmExportProcessExpression, { params })
  }
}
